home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT8 / RDCHAR.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-05-10  |  2.7 KB  |  74 lines

  1. ;-----------------------------------------------------------
  2. ;
  3. ;  Program RdChar ( Chapter 8 ) 
  4. ;
  5. ;  Procedure for reading a character + attribute at the address: DH,DL  
  6. ;
  7. ;  Author:  A.I.Sopin      VSU,     Voronezh, 1992
  8. ;
  9. ;  Input parameters
  10. ;
  11. ;  BH - number of a video page  (0, 1, 2, 3)
  12. ;
  13. ;  BL - type of a video adapter (is determined using  VIDTYP)
  14. ;
  15. ;  DH - line of a character (0 --- 49)
  16. ;
  17. ;  DL - column of a character (0 --- 79)
  18. ;
  19. ;  ES - segment address of the videobuffer
  20. ;
  21. ;  Output parameters:
  22. ;
  23. ;  AH  -attribute of the character been read
  24. ;
  25. ;  AL  -the character been read
  26. ;
  27. ;-----------------------------------------------------------
  28.  
  29. .MODEL  SMALL
  30. .CODE
  31. RDCHAR  PROC    FAR
  32.         PUBLIC  RDCHAR
  33.         push    bx                ;
  34.         push    cx                ;
  35.         push    dx                ;
  36.         push    di                ;
  37.         push    es                ;
  38.         mov     CS:CGA,bl         ;  video adapter type
  39. ;  Computing the address of the charpacter + attribute in the video buffer
  40.         mov     al,dh             ;  multiplier - line of the cursor
  41.         mov     cl,160            ;  multiplier =160
  42.         mul     cl                ;  computing offset of video buffer
  43.         xor     cx,cx             ;
  44.         mov     cl,dl             ;  add column of cursor
  45.         sal     cx,1              ;  *2
  46.         add     ax,cx             ;  computing offset of a character
  47.         mov     di,ax             ;
  48.         mov     bl,bh             ;  BL - number of video page
  49.         mov     cl,12             ;  quantity of shifts *4096
  50.         sal     bx,cl             ;  number of page *4096
  51.         add     di,bx             ;  address taking offset into account
  52.         cmp     CS:CGA,1          ;  CGA ?
  53.         jne     Read              ;  don't check for the interference
  54.         mov     dx,3DAH           ;  status register
  55. ;  Waiting for the completition of beam retrace
  56. Cycle0: in      al,dx             ;  reading status register
  57.         test    al,1              ;  is retrace being executed ?
  58.         jnz     Cycle0            ;  yes, wait for a completion
  59. ;  Check, is reading is possble ( to avoid interference)
  60. Cycle1: in      al,dx             ;  reading status register
  61.         test    al,1              ;  is retrace being executed (may we read) ?
  62.         jz      Cycle1            ;  no, continue testing
  63. Read:   mov     ax,ES:[DI]        ;  pass the character + attribute
  64. ;  Restoring the registers been used and exit
  65.         pop     es
  66.         pop     di
  67.         pop     dx
  68.         pop     cx
  69.         pop     bx
  70.         RETF
  71. CGA     DB      0                       ;  1 - CGA indicator
  72. RDCHAR  ENDP
  73.         END
  74.